package com.lancoo.znbkxx.teacher.widget;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RadioGroup;

import com.lancoo.znbkxx.teacher.R;

/**
 * 筛选popupwindow
 */
public class FilterPopupWindow extends PopupWindow {
    private Context context;
    private View mPopView;
    private View.OnClickListener onClickListener;
    private RadioGroup.OnCheckedChangeListener onCheckedChangeListener;

    public FilterPopupWindow(Context context, View.OnClickListener onClickListener, RadioGroup.OnCheckedChangeListener onCheckedChangeListener) {
        super(context);
        this.context = context;
        this.onClickListener = onClickListener;
        this.onCheckedChangeListener = onCheckedChangeListener;
        initView(context, onClickListener, onCheckedChangeListener);
    }

    @Override
    public View getContentView() {
        return mPopView;
    }

    private void initView(Context context, View.OnClickListener onClickListener, RadioGroup.OnCheckedChangeListener onCheckedChangeListener) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mPopView = inflater.inflate(R.layout.view_expand, null);
        RadioGroup rgWcqk = mPopView.findViewById(R.id.rg_wcqk);
        RadioGroup rgZdsj = mPopView.findViewById(R.id.rg_zdsj);
        ImageView mReset = mPopView.findViewById(R.id.iv_reset);
        ImageView mConfig = mPopView.findViewById(R.id.iv_config);
        rgWcqk.setOnCheckedChangeListener(onCheckedChangeListener);
        rgZdsj.setOnCheckedChangeListener(onCheckedChangeListener);
        mReset.setOnClickListener(onClickListener);
        mConfig.setOnClickListener(onClickListener);
        this.setContentView(mPopView);
        this.setWidth(WindowManager.LayoutParams.MATCH_PARENT);
        this.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
        this.setOutsideTouchable(true);
        this.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
        this.setFocusable(true);
    }
}
